#include <bits/stdc++.h>
using namespace std;
bool matchCore(char* str,char* pattern)
{
    if(*str=='\0' && *pattern == '\0')
        return true;
    if(*str!='\0' && *pattern == '\0')
        return false;
    if(*(pattern+1) == '*')
    {
        if(*pattern == *str||(*pattern == '.' &&*str!='\0'))
        {
            return matchCore(str+1,pattern+2)//匹配b和b*
                   ||matchCore(str+1,pattern)//匹配b*
                   ||matchCore(str,pattern+2);//跳过*
        } else{
            return matchCore(str,pattern+2);//不匹配就跳过*
        }
    }
    if(*str == *pattern||(*pattern=='.' && *str != '\0'))
        return matchCore(str+1,pattern+1);
    return false;
}
bool match(char* str,char* pattern)
{
    if(str == nullptr||pattern == nullptr)
        return false;
    else
        return matchCore(str,pattern);
}
int main() {
    char str[] = "aba";
    char partern[] = "ab*ab*a";
    if(match(str,partern))
        cout<<"匹配";
    else
        cout<<"不匹配";
    return 0;
}